package com.granada.service.base;

import com.granada.common.Curd;
import com.granada.entity.SysPermission;
import com.granada.behaviour.interfaces.PermissionBehavior;
import com.granada.model.common.Permission;
import com.granada.vo.resp.PageVO;
import com.granada.vo.resp.PermissionRespNode;

import java.util.List;
import java.util.Set;

public abstract class PermissionService<T> implements Curd, PermissionBehavior {
    protected Permission permissionModel;
    protected PermissionBehavior permissionBehavior;
    public PermissionService(
            Permission permissionModel,
            PermissionBehavior permissionBehavior
        ) {
        this.permissionModel = permissionModel;
        this.permissionBehavior = permissionBehavior;
    }

    @Override
    public Long add() throws Exception {
        this.permissionModel.add();
        return null;
    }

    @Override
    public void update() throws Exception {
        this.permissionModel.update();
    }

    @Override
    public void delete() throws Exception {
        this.permissionModel.delete();
    }
    public void batchDelete() throws Exception{

    }

    @Override
    public T getOne() throws Exception {
        return (T) this.permissionModel.getOne();
    }

    @Override
    public T getSearchOne() throws Exception {
        return (T) this.permissionModel.getSearchOne();
    }

    @Override
    public List<T> getAll() throws Exception {
        return this.permissionModel.getAll();
    }

    @Override
    public List<T> getSearchAll() throws Exception {
        return this.permissionModel.getSearchAll();
    }

    @Override
    public PageVO<T> getList() throws Exception {
        return this.permissionModel.getList();
    }

    @Override
    public PageVO<T> getSearchList() throws Exception {
        return this.permissionModel.getSearchList();
    }

    @Override
    public List<PermissionRespNode> permissionTreeList(Long userId) throws Exception {
        return permissionBehavior.permissionTreeList(userId);
    }

    @Override
    public List<SysPermission> selectAllPlatform(Long userId) throws Exception {
        return permissionBehavior.selectAllPlatform(userId);
    }

    @Override
    public List<PermissionRespNode> selectBig() throws Exception {
        return permissionBehavior.selectBig();
    }

    @Override
    public List<PermissionRespNode> selectAllMenuByTree(Long permissionId) throws Exception {
        return permissionBehavior.selectAllMenuByTree(permissionId);
    }

    @Override
    public List<PermissionRespNode> platformSelectAllByTree(Long userId) throws Exception {
        return permissionBehavior.platformSelectAllByTree(userId);
    }

    @Override
    public List<PermissionRespNode> selectAllByTree() throws Exception {
        return permissionBehavior.selectAllByTree();
    }

    @Override
    public List<SysPermission> selectAllping() throws Exception {
        return permissionBehavior.selectAllping();
    }

    @Override
    public Set<String> getPermissionsByUserId(Long userId) throws Exception {
        return permissionBehavior.getPermissionsByUserId(userId);
    }

}
